package com.itzhoun.consumer;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author 周楠
 * @Date 2022/09/12/上午 4:04
 */
@Component
public class RouteReceiver {


    @Order(0)
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "direct", type = "direct"),
                    key = {"info", "warn", "error"}//绑定交换机
            )
    })
    public void receiver1(String message){
        System.out.println("路由模式 message1:" + message);

    }

    @Order(1)
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "direct", type = "direct"),
                    key = {"info"}//绑定交换机
            )
    })
    public void receiver2(String message){
        System.out.println("路由模式 message2:" + message);

    }
}
